﻿{:W('Nav',array('name'=>'商品列表','act'=>'添加商品','URL'=>'addGoods'))}
<script type="text/javascript" src="__PUBLIC__/Js/js/utils.js"></script>
<script type="text/javascript" src="__PUBLIC__/Js/js/listtable.js"></script><!-- 商品搜索 -->
<div class="form-div">
    <form action="javascript:searchGoods()" name="searchForm">
        <img src="__PUBLIC__/Images/images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH"/>
        <!-- 分类 -->
        <select name="cat_id">
            <option value="0">所有分类</option>
        </select>
        <!-- 上架 -->
        <select name="is_on_sale">
            <option value=''>全部</option>
            <option value="1">上架</option>
            <option value="0">下架</option>
        </select>
        <!-- 审核状态-->
        <select name="is_check">
            <option value=''>全部</option>
            <option value="5">未审核</option>
            <option value="1">审核提交</option>
            <option value="2">药师审核通过</option>
            <option value="3">审核管理员审核通过</option>
        </select>
        关键字 <input type="text" name="keyword" size="15"/>
        <input type="submit" value=" 搜索 " class="button"/>
    </form>
</div>


<script language="JavaScript">
    function searchGoods() {
        listTable.filter['cat_id'] = document.forms['searchForm'].elements['cat_id'].value;
        listTable.filter['is_on_sale'] = document.forms['searchForm'].elements['is_on_sale'].value;
        listTable.filter['is_check'] = document.forms['searchForm'].elements['is_check'].value;
        listTable.filter['keyword'] = Utils.trim(document.forms['searchForm'].elements['keyword'].value);
        listTable.filter['page'] = 1;
        listTable.loadList();
    }
</script>
<!-- 商品列表 -->
<form method="post" action="" name="listForm" onsubmit="return confirmSubmit(this)">
    <!-- start goods list -->
    <div class="list-div" id="listDiv">
        <table cellpadding="3" cellspacing="1">
            <tr>
                <th>
                    <input onclick='listTable.selectAll(this, "checkboxes")' type="checkbox"/>
                    <a href="javascript:listTable.sort('goods_id'); ">编号</a><img
                        src="__PUBLIC__/Images/images/sort_desc.gif"/></th>
                <th><a href="javascript:listTable.sort('goods_name'); ">商品名称</a></th>
                <th><a href="javascript:listTable.sort('goods_sn'); ">货号</a></th>
                <th><a href="javascript:listTable.sort('shop_price'); ">价格</a></th>
                <th><a href="javascript:listTable.sort('examine_status'); ">审核状态</a></th>
                <th><a href="javascript:listTable.sort('is_on_sale'); ">上架</a></th>
                <th><a href="javascript:listTable.sort('sort_order'); ">推荐排序</a></th>
                <th><a href="javascript:listTable.sort('goods_number'); ">库存</a></th>
                <th><a href="javascript:listTable.sort('virtual_sales'); ">虚拟销量</a></th>
                <th>操作</th>
            </tr>
            <foreach name="goodsArr" item="v">
                <tr>
                    <td><input type="checkbox" name="checkboxes[]" value='{$v.id}'/>{$v.id}</td>
                    <td class="first-cell" style=""><span>{$v.name}</span></td>
                    <td><span>{$v.goods_sn}</span></td>
                    <td align="right"><span>{$v.shop_price} </span></td>
                    <td align="center">
                        <span name="checked_{$v['id']}"><if condition='$v.status eq 3'>审核管理员审核通过
                            <elseif condition='$v.status eq 1'/>
                            审核提交
                            <elseif condition='$v.status eq 2'/>
                            药师审核通过
                            <else/>
                            未审核
                        </if></span>
                    </td>

                        <td align="center"><img
                                src="__PUBLIC__/Images/images/<if condition='$v.is_sale eq 1'>yes<else/>no</if>.gif"
                                onclick="listTable.toggle(this, '{:U(GROUP_NAME.'/Goods/runEdit')}', {$v.id})"/></td>
                        <td align="center"><span onclick="listTable.edit(this, '{:U(GROUP_NAME.'/Goods/runEdit')}','sort', {$v.id})">{$v.sort}</span>
                        </td>
                        <td align="right"><span onclick="listTable.edit(this,'{:U(GROUP_NAME.'/Goods/runEdit')}', 'num', {$v.id})">{$v.num}</span>
                        </td>
                        <td align="center"><span
                                onclick="listTable.edit(this,'{:U(GROUP_NAME.'/Goods/runEdit')}','sale_num', {$v.id})">{$v.sale_num}</span></td>

                    <td align="center">
                        <a href="{:U('/Index/Goods/index/id/'.$v['id'])}" target="_blank" title="查看">
                            <img src="__PUBLIC__/Images/images/icon_view.gif" width="16" height="16" border="0"/>
                        </a>
                                <a href="{:U('/eg_'.$v['id'])}" title="编辑">
                                    <img src="__PUBLIC__/Images/images/icon_edit.gif" width="16" height="16" border="0"/>
                                </a>
                                <a href="{:U(GROUP_NAME.'/Goods/toTrach/',array('type'=>'1','id'=>$v['id']))}" title="回收站">
                                    <img src="__PUBLIC__/Images/images/icon_trash.gif" width="16" height="16" border="0"/>
                                </a>
                        <if condition="$v.status eq 0">
                                <a name="check_{$v['id']}" href="javascript:void 0;" onclick="submitCheck({$v['id']},'{:U(GROUP_NAME.'/Goods/runCheck')}',1)"title="提交">
                                    <img src="__PUBLIC__/Images/images/check.png" width="16" height="16" border="0"/>
                                </a>
                        </if>
                    </td>
                </tr>
            </foreach>
        </table>
        <!-- end goods list -->
        <!-- 分页 -->
        <table id="page-table" cellspacing="0">
            <tr>
                <td align="right" nowrap="true">
                    <!-- $Id: page.htm 14216 2008-03-10 02:27:21Z testyang $ -->
                    <div id="turn-page" style="margin-top: 5px;text-align: center">
                        总计 <span id="totalRecords">{$goodsArr|count}</span>
                        个记录</div>
                </td>
            </tr>
        </table>
    </div>
</form>
<div id="footer">
    版权所有 &copy; 2005-2017 上海商派软件有限公司，并保留所有权利。
</div>
<script language="JavaScript">
    function submitCheck($id,$url,$status){

        var xmlhttp=new XMLHttpRequest();
        xmlhttp.open("POST",$url,false);
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlhttp.send("id=" + $id + "&status=" +$status);
//        alert(xmlhttp.responseText);
        if(xmlhttp.responseText){
            if($status==1){
                $str='审核提交'
            }else if($status==2){
                $str='药师审核通过'
            }else {
                $str='审核管理员审核通过'
            }
            document.getElementsByName('check_'+$id)[0].style.display='none';
            document.getElementsByName('checked_'+$id)[0].innerHTML =$str;

        }else{
            alert('请求出错，请稍后重试');
        }
    }
    document.onmousemove = function (e) {
        var obj = Utils.srcElement(e);
        if (typeof(obj.onclick) == 'function' && obj.onclick.toString().indexOf('listTable.edit') != -1) {
            obj.title = '点击修改内容';
            obj.style.cssText = 'background: #278296;';
            obj.onmouseout = function (e) {
                this.style.cssText = '';
            }
        }
        else if (typeof(obj.href) != 'undefined' && obj.href.indexOf('listTable.sort') != -1) {
            obj.title = '点击对列表排序';
        }
    }

    var MyTodolist;
    function showTodoList(adminid) {
        if (!MyTodolist) {
            var global = $import("../js/global.js", "js");
            global.onload = global.onreadystatechange = function () {
                if (this.readyState && this.readyState == "loading")return;
                var md5 = $import("js/md5.js", "js");
                md5.onload = md5.onreadystatechange = function () {
                    if (this.readyState && this.readyState == "loading")return;
                    var todolist = $import("js/todolist.js", "js");
                    todolist.onload = todolist.onreadystatechange = function () {
                        if (this.readyState && this.readyState == "loading")return;
                        MyTodolist = new Todolist();
                        MyTodolist.show();
                    }
                }
            }
        }
        else {
            if (MyTodolist.visibility) {
                MyTodolist.hide();
            }
            else {
                MyTodolist.show();
            }
        }
    }

    if (Browser.isIE) {
        onscroll = function () {
            //document.getElementById('calculator').style.top = document.body.scrollTop;
            document.getElementById('popMsg').style.top = (document.body.scrollTop + document.body.clientHeight - document.getElementById('popMsg').offsetHeight) + "px";
        }
    }

    if (document.getElementById("listDiv")) {
        document.getElementById("listDiv").onmouseover = function (e) {
            obj = Utils.srcElement(e);

            if (obj) {
                if (obj.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode;
                else if (obj.parentNode.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode.parentNode;
                else return;

                for (i = 0; i < row.cells.length; i++) {
                    if (row.cells[i].tagName != "TH") row.cells[i].style.backgroundColor = '#F4FAFB';
                }
            }

        }

        document.getElementById("listDiv").onmouseout = function (e) {
            obj = Utils.srcElement(e);

            if (obj) {
                if (obj.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode;
                else if (obj.parentNode.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode.parentNode;
                else return;

                for (i = 0; i < row.cells.length; i++) {
                    if (row.cells[i].tagName != "TH") row.cells[i].style.backgroundColor = '#FFF';
                }
            }
        }

        document.getElementById("listDiv").onclick = function (e) {
            var obj = Utils.srcElement(e);

            if (obj.tagName == "INPUT" && obj.type == "checkbox") {
                if (!document.forms['listForm']) {
                    return;
                }
                var nodes = document.forms['listForm'].elements;
                var checked = false;

                for (i = 0; i < nodes.length; i++) {
                    if (nodes[i].checked) {
                        checked = true;
                        break;
                    }
                }

                if (document.getElementById("btnSubmit")) {
                    document.getElementById("btnSubmit").disabled = !checked;
                }
                for (i = 1; i <= 10; i++) {
                    if (document.getElementById("btnSubmit" + i)) {
                        document.getElementById("btnSubmit" + i).disabled = !checked;
                    }
                }
            }
        }

    }
</script>
</body>
</html>    